
import {Base64} from 'js-base64';
const userData = {
    actions: {

    },
    getters: {
        isAuthenticated: (state) => state.isAuthenticated,
        getUkeyId: (state) => Base64.decode(state.ukeyId)
    },
    mutations: {
        SET_PULLON: (state, flag) => {
            state.putOn = flag
        },
        SET_CERTFLAG: (state) => {
            state.cert = true
        },
        SET_RECERT: (state) => {
            state.cert = false
        },
        SET_SETDATA: (state) => {
            state.name = '',
            state.token ='',
            state.pactId = '',
            state.projName = '',
            state.projId = '',
            state.userName = '',
            state.userId = '',
            state.unitName = '',
            state.loginType = 1,
            state.certsn = '', 
            state.Thumbprint = '',
            state.unitId = 0,
            state.topProjId = '',
            state.connectId = '',
            state.isAdmin = false,
            state.signId = ''
        },
        SET_PACTTYPE: (state, pactType) => {
            state.pactType = pactType
        },

        SET_ISSELFPACT: (state, isSelfPact) => {
            state.isSelfPact=isSelfPact
        },
        SET_LOGINDATA: (state, data) => {
            state.userName = data.userName
            state.userId = data.userId
            state.pactName = data.pactName
            state.pactId = data.pactId
            state.projName = data.projName
            state.projId = data.projId
            state.loginType = data.loginType
            state.token = data.token
            state.topProjId = data.topProjId
            state.connectId = data.connectId
            state.mustUKeySign = data.mustUKeySign
            state.roadLevel = data.roadLevel,
            state.roadLevelName = data.roadLevelName
            state.isAdmin = data.isAdmin
            state.pactType = data.pactType
            state.isSelfPact = data.isSelfPact
        },
        SET_UNITDATA: (state, data) => {
            state.checkName = data.checkTypeName,
            state.orgId= data.orgId,
            state.unitId = data.unitId,
            state.unitName= data.unitName,
            state.deptId = data.deptId,
            state.deptName= data.deptName,
            state.checkType = data.checkType
        },
        SET_MUSTKEY: (state, mustUKeySign) => {
            state.mustUKeySign = mustUKeySign
        },
        SET_PACT: (state, pactId,pactName) => {
            state.pactName = pactName
            state.pactId = pactId
        },
        SET_PROJ: (state, sprojId, projName) => {
            state.projId = projId
            state.projName = projName
        },
        SET_ROAD: (state, roadLevel,roadLevelName) => {
            state.roadLevel = roadLevel,
            state.roadLevelName = roadLevelName
        },
        SET_TOPPROJID: (state, topProjId) => {
            state.topProjId = topProjId
        },
        SET_CERT(state, data){
            state.Thumbprint =  data.value;
            state.certsn = data.certsn; 
            state.deviceType = String(data.deviceType);
            state.ukeyId = Base64.encode(data.password)
            state.signId = data.signId;
            state.validToDate = data.validToDate;
        }
    },
    state: {
        name: '',
        token:'',
        pactName:null,
        pactId:'',
        projName:null,
        projId:'',
        userName:'',
        userId: '',
        unitName:null,
        unitId:0,
        deptName:null,
        deptId:0,
        orgId:0,
        roadLevel:null,
        roadLevelName:null,
        checkType:0,
        checkName:null,
        loginType:1,  //登陆类型 0：普通帐号登录 2：文件证书 4：UKEY证书
        certsn:'', // ukey序列号
        Thumbprint:'',
        cert:false,
        putOn:false,
        deviceType:'',
        ukeyId:'',
        topProjId: '',
        connectId: null,
        mustUKeySign:0,
        isAdmin:false,
        pactType: '',
        isSelfPact: 0, //当前合同段是否自已所属 0可以切换身份 1不可以切换身份
        signId: '',
        validToDate: '', //当前ukey有效日期
    }
}

export default userData